<template>
  <div class="Header">
    <div class="order_list mBtm16" v-for="(item, index) in props.orderList" @click="itemClickCFun(item)">
      <div class="order_list_top items c99">
        <div class="order_list_top_code items">
          <div>После заказа: {{ item.order_goods[0]?.order_id }}</div>
          <img style="cursor: pointer" src="/src/assets/icons/account/order_code.png" alt="" class="mLeft8">
        </div>
        <div class="order_list_top_status">Статус заказа</div>
        <div class="order_list_top_price">Стоимость единицы</div>
      </div>
      <div class="order_list_bottom items">
        <img class="order_list_bottom_img" :src="item.order_goods[0]?.first_img" alt="">
        <div class="order_list_bottom_detail">
          <div>
            <div>{{ item.order_goods[0]?.subject_trans }}</div>
            <div class="mTop10 c99">Стиль：{{ item.order_goods[0]?.attribute_name_trans }}</div>
          </div>
          <div>×2</div>
        </div>
        <div class="order_list_bottom_status">{{ filtrationStatus(item.order_goods[0]?.order_status) }}</div>
        <div class="order_list_bottom_price">{{item.order_pay_price}}₽</div>
        <div class="order_list_bottom_cancel">
          <div class="c99">Отменить</div>
          <div class="mTop16">Торговцы</div>
        </div>
        <div class="order_list_bottom_btn" v-if="item.order_goods[0]?.order_status == 'waitbuyerpay'">
          <!-- <div class="cFF8">23: 59: 12</div> -->
          <div class="btn">Платежи</div>
        </div>
        <div class="order_list_bottom_btn" v-if="item.order_goods[0]?.order_status == 'cancel'">
          <div class="c99">Отменить</div>
          <div>Торговцы</div>
        </div>
        <div class="order_list_bottom_btn" v-if="item.order_goods[0]?.order_status == 'waitbuyerreceive'">
          <div class="btn">Получение</div>
          <div class="c99">Логистика</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" name="Shopping_list" setup>
import {ref, reactive, defineProps, defineEmits} from "vue";

const emits = defineEmits(['itemClick'])
const props = defineProps({
  type: {
    type: String,
    default: "1"
  },
  num: {
    type: Number,
    default: 24
  },
  orderList:{
    type:Array,
    default:()=>[]
  }
});
const itemClickCFun = (item: any) => {
  emits('itemClick', item)
}
function filtrationStatus(status:string){
  let text = ''
  switch(status){
    case 'waitbuyerpay':
      text = 'Ожидаемые платежи'
      break
    case 'waitsellersend':
      text = 'Ожидание отгрузки'
      break
    case 'waitbuyerreceive':
      text = 'Ожидаемые товары'
      break
    case 'confirm_goods':
      text = 'Груз принят'
      break
    case 'success':
      text = 'Завершено'
      break
    case 'cancel':
      text = 'Сделка отменяется'
      break
    case 'terminated':
      text = 'Отмени сделку'
      break
    case 'delete':
      text = 'Исключить'
      break
    case 'after_sales':
      text = 'После продажи'
      break
  }
  return text
}

</script>

<style lang="less" scoped>
.order_list {
  width: 1124px;
  height: 194px;
  border-radius: 8px;
  border: 1px solid #CCCCCC;
  cursor: pointer;

  &_top {
    height: 14px;
    padding: 20px;
    background: #F6F6F6;
    font-size: 14px;
    font-weight: 400;
    line-height: 14px;

    &_code {
      width: 477px;

      img {
        width: 18px;
        height: 18px;
      }
    }

    &_status {
      width: 152px;
    }

    &_price {
    }
  }

  &_bottom {
    padding: 20px;
    display: flex;
    align-items: center;

    &_img {
      width: 100px;
      height: 100px;
      border-radius: 4px;
    }

    &_detail {
      padding-left: 12px;
      width: 365px;
      height: 100px;
      font-family: PingFang SC;
      font-size: 13px;
      font-weight: 400;
      line-height: 15.6px;
      // border: 1px solid black;
      display: flex;
      justify-content: space-between;
      flex-direction: column;

    }

    &_status {
      width: 114px;
      height: 34px;
      font-family: PingFang SC;
      font-size: 14px;
      font-weight: 400;
      line-height: 16.8px;
      color: #0070E9;
      text-align: center;
    }

    &_price {
      width: 206px;
      height: 16px;
      font-family: PingFang SC, PingFang SC;
      font-weight: bold;
      font-size: 16px;
      color: #F83C57;
      line-height: 16px;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }

    &_cancel {
      width: 160px;
      height: 140px;
      margin-top: -20px;
      border-left: 1px solid #F6F6F6;
      border-right: 1px solid #F6F6F6;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
    }

    &_btn {
      width: 160px;
      height: 140px;
      margin-top: -20px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;

      .btn {
        width: 91px;
        height: 34px;
        border-radius: 8px;
        background: #0070E9;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #FFFFFF;
        font-family: PingFang SC;
        font-size: 12px;
        font-weight: 400;
        line-height: 12px;
        margin-top: 12px;
      }
    }
  }
}
</style>
